package com.foreknow.demo6;

import java.util.Scanner;

public class Zuoye {
    public static void main(String[] args) {
        boolean isLogin = false;//登录的标识位
        String account = "admin";
        String password = "123";
        String answer ="y";
        double money =10000;
        double inmoney = 0;
        double oumoney = inmoney-money;

        Scanner input = new Scanner(System.in);
        System.out.println("------------------------------");
        System.out.println("******   欢迎登录   ******* ");
        System.out.println("****** 中国人民银行 ******");
        System.out.println("               版本1.0****");
        System.out.println("------------------------------");
        for (int i = 1; i <= 3; i++) {
            System.out.println("请输入账号");
            String inputaccount = input.next();
            System.out.println("请输入密码");
            String inputpassword = input.next();
            if (inputaccount.equals(account) && inputpassword.equals(password)) {
                System.out.println("欢迎登录");
                break;
            } else if (i < 3) {
                System.out.println("账户名或密码错，请重新输入今日还剩余" + (3 - i) + "次机会！");
            } else {
                System.out.println("密码错误3次，吞卡，请找老司机处理");
            }
        }
        isLogin = true;
        if (isLogin){
            do {
                System.out.println("1.查询余额，2.存款，3.取款，4.修改密码，5.退出");

                int choice = input.nextInt();
                switch (choice) {
                    case 1:
                        money=10000;
                        System.out.println("您的余额为"+money);
                        break;
                    case 2:
                        System.out.println("请输入您要存款的金额");
                        double inputmoney  = input.nextDouble();
                        if (inputmoney >= 10000){
                            System.out.println("单次取款金额超过1万元");
                        }else  if (inputmoney < 0){
                            System.out.println("存款金额错误");
                        }else if (inputmoney % 100 !=0){
                            System.out.println("请输入100的整数倍存款");
                        }else if (inputmoney <= 10000 && inputmoney> 0){
                            inmoney = inputmoney+money;
                            System.out.println("存款成功，当前余额为"+inmoney);
                        }
                        break;
                    case 3:
                        System.out.println("请输入您要取款的金额");
                        double outmoney  = input.nextDouble();
                        if (outmoney > money){
                            System.out.println("余额不足");
                        }else if (outmoney >3000){
                            System.out.println("单次取款金额超过3000");
                        }else  if (outmoney < 0){
                            System.out.println("取款金额错误");
                        }else if (outmoney % 100 !=0){
                            System.out.println("请取出100的整数倍存款");
                        }else  if (outmoney <= 3000 && outmoney> 0){
                            System.out.println("取款成功，当前余额为"+oumoney);
                        }
                        break;
                    case 4:
                        System.out.println("请输入旧密码");
                        String newpassword = input.next();
                        if (newpassword.equals(password)){
                            System.out.println("请输入新密码");
                            String neewpassword = input.next();
                            System.out.println("请再次输入新密码");
                            String nnewpassword = input.next();
                            if (nnewpassword.equals(neewpassword)){
                                System.out.println("密码修改成功");
                                System.out.println("当前密码为"+nnewpassword);
                            }else {
                                System.out.println("两次输入密码不一致，请重新输入");
                                System.out.println("当前密码为"+password);
                            }
                        }else {
                            System.out.println("旧密码输入错误");
                            System.out.println("当前密码为"+password);
                        }
                        break;
                    case 5:
                        System.out.println("退出成功");
                        break;
                }
                System.out.println("是否继续(y/n)");
                answer = input.next();
            }while (answer.equals("y"));
            if (answer.equals("n")) {
                System.out.println("系统退出！！！！");
            }
        }

    }
}
